<?php

namespace App\Http\Resources\Backend;

use Illuminate\Http\Resources\Json\Resource;

/**
 * Class SchoolResource
 * @package App\Http\Resources\Backend
 */
class SchoolResource extends Resource
{
    /**
     * @param \Illuminate\Http\Request $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'rule' => new SchoolRuleResource($this->whenLoaded('rule')),
            'name' => $this->name,
            'detail_address' => $this->detail_address,
            'contact_name' => $this->contact_name,
            'contact_phone' => $this->contact_phone,
            'dev_code' => $this->dev_code,
            'objectid' => $this->objectid,
            'key' => $this->key,
            'key_id' => $this->key_id,
            'status' => $this->status,
            'province' => $this->province,
            'city' => $this->city,
            'country' => $this->country,
            'address' => $this->address,
            'created_at' => $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null,
            'updated_at' => $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null
        ];
    }
}
